import request from '@/utils/request'

// 获取SPU列表数据的接口
// GET /admin/product/{page}/{limit} 携带三个参数：page limit Id3
export const reqSpuList = (page, limit,Id3) => request({
    url: `/admin/product/${page}/${limit}`,
    method:'get',
    params:{Id3}
})

// 获取某一个spu信息的接口
// GET /admin/product/getSpuById/{spuId}
export const reqSpu = (spuId) => request({
    url: `/admin/product/getSpuById/${spuId}`,
    method:'get'
})

// 获取品牌数据的接口
// GET /admin/product/baseTrademark/getTrademarkList
export const reqTrademarkList = () => request({
    url: `/admin/product/baseTrademark/getTrademarkList`,
    method:'get'
})

// 获取spu图片的接口
// GET /admin/product/spuImageList/{spuId}
export const reqSpuImageList = (spuId) => request({
    url: `/admin/product/spuImageList/${spuId}`,
    method:'get'
})

// 获取平台全部销售属性的接口---三个
// GET /admin/product/baseSaleAttrList
export const reqBaseSaleAttrList = () => request({
    url: `/admin/product/baseSaleAttrList`,
    method:'get'
})

// 修改|添加spu，修改或添加的区别就是携带的参数是否有id
// POST /admin/product/saveSpuInfo（添加）
// POST /admin/product/updateSpuInfo（修改）
export const reqAddOrUpdateSpu = (spuInfo) => {
    // 携带的参数有id---修改spu
    if(spuInfo.id) {
        return request({
            url: `/admin/product/updateSpuInfo`,
            method:'post',
            data:spuInfo
        })
    } else {// 携带的参数没有id---添加spu
        return request({
            url: `/admin/product/saveSpuInfo`,
            method:'post',
            data:spuInfo
        })
    }
}

// 删除spu
// DELETE /admin/product/deleteSpu/{spuId}
export const reqDeleteSpu = (spuId) => request({
    url: `/admin/product/deleteSpu/${spuId}`,
    method:'delete'
})

// 获取sku图片的接口
// GET /admin/product/spuImageList/{spuId}
export const reqSpuImageLists = (spuId) => request({
    url: `/admin/product/spuImageList/${spuId}`,
    method:'get'
})

// 获取sku销售属性的接口
// GET /admin/product/spuSaleAttrList/{spuId}
export const reqSpuSaleAttrList = (spuId) => request({
    url: `/admin/product/spuSaleAttrList/${spuId}`,
    method:'get'
})

// 获取sku平台属性数据的接口
// GET /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
export const reqAttrInfoList = (category1Id,category2Id,category3Id) => request({
    url: `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`,
    method:'get'
})

// skuForm保存
// POST /admin/product/saveSpuInfo
export const reqAddSku = (skuInfo) => request({
    url: `/admin/product/saveSpuInfo`,
    method:'post',
    data:skuInfo
})

// 获取sku列表数据的接口（查看按钮）
// GET /admin/product/findBySpuId/{spuId}
export const reqSkuList = (spuId) => request({
    url: `/admin/product/findBySpuId/${spuId}`,
    method:'get',
})